package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.DevicePackage;
import com.ruoyi.manage.service.IDevicePackageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 器械包Controller
 * 
 * @author liuyangyang
 * @date 2025-06-04
 */
@Api("器械包管理")
@RestController
@RequestMapping("/manage/devicepackage")
public class DevicePackageController extends BaseController
{
    @Autowired
    private IDevicePackageService devicePackageService;

    /**
     * 查询器械包列表
     */
    @ApiOperation("查询器械包列表")
    @PreAuthorize("@ss.hasPermi('manage:devicepackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(DevicePackage devicePackage)
    {
        startPage();
        List<DevicePackage> list = devicePackageService.selectDevicePackageList(devicePackage);
        return getDataTable(list);
    }

    /**
     * 导出器械包列表
     */

    @PreAuthorize("@ss.hasPermi('manage:devicepackage:export')")
    @Log(title = "器械包", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DevicePackage devicePackage)
    {
        List<DevicePackage> list = devicePackageService.selectDevicePackageList(devicePackage);
        ExcelUtil<DevicePackage> util = new ExcelUtil<DevicePackage>(DevicePackage.class);
        util.exportExcel(response, list, "器械包数据");
    }

    /**
     * 获取器械包详细信息
     */
    @ApiOperation("获取器械包详细信息")
    @PreAuthorize("@ss.hasPermi('manage:devicepackage:query')")
    @GetMapping(value = "/{devicePackageId}")
    public AjaxResult getInfo(@PathVariable("devicePackageId") Long devicePackageId)
    {
        return success(devicePackageService.selectDevicePackageByDevicePackageId(devicePackageId));
    }

    /**
     * 新增器械包
     */
    @ApiOperation("新增器械包")
    @PreAuthorize("@ss.hasPermi('manage:devicepackage:add')")
    @Log(title = "器械包", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DevicePackage devicePackage)
    {
        return toAjax(devicePackageService.insertDevicePackage(devicePackage));
    }

    /**
     * 修改器械包
     */
    @ApiOperation("修改器械包")
    @PreAuthorize("@ss.hasPermi('manage:devicepackage:edit')")
    @Log(title = "器械包", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DevicePackage devicePackage)
    {
        return toAjax(devicePackageService.updateDevicePackage(devicePackage));
    }

    /**
     * 删除器械包
     */
    @ApiOperation("删除器械包")
    @PreAuthorize("@ss.hasPermi('manage:devicepackage:remove')")
    @Log(title = "器械包", businessType = BusinessType.DELETE)
	@DeleteMapping("/{devicePackageIds}")
    public AjaxResult remove(@PathVariable Long[] devicePackageIds)
    {
        return toAjax(devicePackageService.deleteDevicePackageByDevicePackageIds(devicePackageIds));
    }
}